const form = layui.form
const layer = layui.layer
//密码校验规则
form.verify({
    pass: [
        /^[\S]{6,12}$/
        , '密码必须6到12位，且不能出现空格'
    ]
});

$('#loginForm').on('submit', function (e) {
  // alert(555)
    e.preventDefault()
    let newData = $(this).serialize()
    console.log(newData);
    axios.post('/index/login',newData).then(({ data: res }) => {
        // console.log(res);
        if (res.errno !== 0) {
            return layer.msg(`${res.errmsg},请重新输入`,{icon: 2})
        }
        layer.msg(
            '登录成功，即将跳转到后台首页',
            {
                icon: 1,
                time: 2000
            },
            function () {
                location.href = "index.html"
            },
         
         
        )
        localStorage.setItem('loginToken', res.data.token)
    })


})
